package org.dromara.learning_xq.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.dromara.learning_xq.entity.AsTeachingMaterial;
import org.dromara.learning_xq.entity.dto.AsTeachingMaterialDto;

import java.util.List;

@Mapper
public interface AsTeachingMaterialMapper extends BaseMapper<AsTeachingMaterial> {


    @Select("SELECT \n" +
        "    act.*,\n" +
        "    asch.id,\n" +
        "    asch.chapter_affiliation,\n" +
        "    asch.belonging_section\n" +
        "FROM \n" +
        "    as_teaching_material act\n" +
        "LEFT JOIN \n" +
        "    as_chapter_content asch \n" +
        "ON \n" +
        "    act.content_id = asch.id;\n")
    List<AsTeachingMaterialDto> selverAll(AsTeachingMaterialDto asTeachingMaterialDto);


    @Select("SELECT " +
        "    act.*, " +
        "    asch.id AS chapter_id, " +
        "    asch.chapter_affiliation, " +
        "    asch.belonging_section " +
        "FROM as_teaching_material act " +
        "LEFT JOIN as_chapter_content asch " +
        "    ON act.content_id = asch.id " +
        "WHERE act.id = #{id}")
    AsTeachingMaterialDto selverId(Long id);



}
